package 区间覆盖;

import java.util.*;

public class Main {
    static int N = 100010;
    static PII[] g = new PII[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int start = in.nextInt();
        int ed = in.nextInt();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            g[i] = new PII(l, r);
        }
        Arrays.sort(g, 0, n);
        int res = 0;
        boolean falg = false;
        for (int i = 0; i < n; i++) {
            int j = i, r_max = Integer.MIN_VALUE;
            while (j < n && g[j].l <= start) {
                r_max = Math.max(r_max, g[j].r);
                j++;
            }
            if (r_max < start) {
                break;
            }
            res++;
            if (r_max >= ed) {
                falg = true;
                break;
            }
            i = j - 1;
            start = r_max;
        }
        if (!falg) {
            res = -1;
        }
        System.out.println(res);
    }

}

class PII implements Comparable<PII> {
    int l, r;

    public PII(int l, int r) {
        this.l = l;
        this.r = r;
    }

    @Override
    public int compareTo(PII o) {
        return Integer.compare(this.l, o.l);
    }
}
